﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import flash.events.*;
    import org.aswing.event.*;

    public class DefaultButtonModel extends EventDispatcher implements ButtonModel {

        protected var group:ButtonGroup;
        protected var enabled:Boolean;
        protected var rollOver:Boolean;
        protected var armed:Boolean;
        protected var pressed:Boolean;
        protected var selected:Boolean;

        public function DefaultButtonModel(){
            this.enabled = true;
            this.rollOver = false;
            this.armed = false;
            this.pressed = false;
            this.selected = false;
        }
        public function isArmed():Boolean{
            return (this.armed);
        }
        public function isRollOver():Boolean{
            return (this.rollOver);
        }
        public function isSelected():Boolean{
            return (this.selected);
        }
        public function isEnabled():Boolean{
            return (this.enabled);
        }
        public function isPressed():Boolean{
            return (this.pressed);
        }
        public function setEnabled(_arg1:Boolean):void{
            if (this.isEnabled() == _arg1){
                return;
            };
            this.enabled = _arg1;
            if (!_arg1){
                this.pressed = false;
                this.armed = false;
            };
            this.fireStateChanged();
        }
        public function setPressed(_arg1:Boolean):void{
            if ((((this.isPressed() == _arg1)) || (!(this.isEnabled())))){
                return;
            };
            this.pressed = _arg1;
            if (((!(this.isPressed())) && (this.isArmed()))){
                this.fireActionEvent();
            };
            this.fireStateChanged();
        }
        public function setRollOver(_arg1:Boolean):void{
            if ((((this.isRollOver() == _arg1)) || (!(this.isEnabled())))){
                return;
            };
            this.rollOver = _arg1;
            this.fireStateChanged();
        }
        public function setArmed(_arg1:Boolean):void{
            if ((((this.isArmed() == _arg1)) || (!(this.isEnabled())))){
                return;
            };
            this.armed = _arg1;
            this.fireStateChanged();
        }
        public function setSelected(_arg1:Boolean):void{
            if (this.isSelected() == _arg1){
                return;
            };
            this.selected = _arg1;
            this.fireStateChanged();
            this.fireSelectionChanged();
        }
        public function setGroup(_arg1:ButtonGroup):void{
            this.group = _arg1;
        }
        public function getGroup():ButtonGroup{
            return (this.group);
        }
        public function addActionListener(_arg1:Function, _arg2:int=0, _arg3:Boolean=false):void{
            addEventListener(AWEvent.ACT, _arg1, false, _arg2);
        }
        public function removeActionListener(_arg1:Function):void{
            removeEventListener(AWEvent.ACT, _arg1);
        }
        public function addSelectionListener(_arg1:Function, _arg2:int=0, _arg3:Boolean=false):void{
            addEventListener(InteractiveEvent.SELECTION_CHANGED, _arg1, false, _arg2);
        }
        public function removeSelectionListener(_arg1:Function):void{
            removeEventListener(InteractiveEvent.SELECTION_CHANGED, _arg1);
        }
        public function addStateListener(_arg1:Function, _arg2:int=0, _arg3:Boolean=false):void{
            addEventListener(InteractiveEvent.STATE_CHANGED, _arg1, false, _arg2);
        }
        public function removeStateListener(_arg1:Function):void{
            removeEventListener(InteractiveEvent.STATE_CHANGED, _arg1);
        }
        protected function fireActionEvent():void{
            dispatchEvent(new AWEvent(AWEvent.ACT));
        }
        protected function fireStateChanged():void{
            dispatchEvent(new InteractiveEvent(InteractiveEvent.STATE_CHANGED));
        }
        protected function fireSelectionChanged():void{
            dispatchEvent(new InteractiveEvent(InteractiveEvent.SELECTION_CHANGED));
        }

    }
}//package org.aswing 
